package javamusic.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;

import javamusic.util.ConexionBDKaraoke;
import javamusic.excepcion.DAOExcepcion;

import javamusic.modelo.Local;

import javamusic.modelo.CalificacionSala;

public class CalificacionSalaDAO extends BaseDAO {
	
	public CalificacionSala insertar(CalificacionSala vo) throws DAOExcepcion {
		String query = "insert into calificacionsala (idcalificacionsala, cliente, idsala, calificacion, comentario) values (?,?,?,?,?)";
		//String query = "select * from local";
		Connection con = null;
		PreparedStatement stmt = null;
		
		try {
			con = ConexionBDKaraoke.obtenerConexion();
			stmt = con.prepareStatement(query);
			
			stmt.setInt(1,vo.getIdcalificacion());
			stmt.setString(2, vo.getCliente());
			stmt.setInt(3, vo.getIdsala());
			stmt.setInt(4, vo.getCalificacion());
			stmt.setString(5, vo.getComentario());
			//stmt.setInt(6, vo.getLocal().getIdlocal());
						
			int i = stmt.executeUpdate();
			if (i != 1) {
				throw new SQLException("No se pudo insertar");
			}
		} catch (SQLException e) {
			System.err.println(e.getMessage());
			throw new DAOExcepcion(e.getMessage());
		} finally {
			this.cerrarStatement(stmt);
			this.cerrarConexion(con);
		}
	return vo;
	}

}